Playfair Cipher
What is a Playfair Cipher?
Playfair cipher is a digraph substitution cipher that encrypts pairs of letters instead of single letters. It uses a 5x5 grid filled with a keyword (excluding J), where encryption rules depend on the position of letter pairs in the grid - whether they form a rectangle, are in same row, or same column. This makes it stronger than simple substitution ciphers as it encrypts letter combinations rather than individual letters.
Key Rules for Playfair Cipher:
1. Create 5x5 grid using keyword (omit J, use I instead)
2. Split message into pairs
3. If pairs have same letter, insert 'X' between
4. If odd letters remain, add 'X' at end
Encryption Rules:
• Same row: Take letter to right (wrap around)
• Same column: Take letter below (wrap around)
• Different row/column: Form rectangle, take letters at horizontal corners in same order
Example with keyword "MONARCHY":
M O N A R
C H Y B D
E F G I K
L P Q S T
U V W X Z
Let's encrypt "HELLO":
1. Split: HE LX LO
2. Process pairs:
• HE → CF (rectangle)
• LX → SU (rectangle))
• LO → PM (rectangle)
Result: "HELLO" → CF SU PM
Decryption uses same rules but reverse direction (left/up instead of right/down).